/**
 * 滑动窗口
 */
function lengthOfLongestSubstring(s: string): number {
    let left = 0
    let right = 1
    let count = s.length ? 1 : 0
    let subTemp = s.slice(left, right)
    let index = -1
    while (right < s.length) {
        index = subTemp.indexOf(s[right])
        if (~index) { // 负数 为 false； 0 or 正数 为 true
            left += index + 1
        } else {
            right++
        }
        subTemp = s.slice(left, right)
        if (count < subTemp.length) {
            count = subTemp.length
        }
    }
    return count
}
exports.lengthOfLongestSubstring = lengthOfLongestSubstring